<?php
	include("connect.php");
	$pilih=mysql_select_db("uwika_krs",$conn);
	$sqlstr="select nrp,kodemk,status from registrasi";
	$hasil1=mysql_query($sqlstr);
	$row = mysql_fetch_row($hasil1);
	do {
		list($nrpx,$kodemkx,$statusx) = $row;
		$sqlstr="select nrp from sks where kodemk='$kodemkx' and nrp='$nrpx'";
		$hasil2=mysql_query($sqlstr);
		list($nrpy) = mysql_fetch_row($hasil2);
		if (!empty($nrpy)) {
			$statusy='ULANG';
		} else {
			$statusy='BARU';
		}
		echo "$nrpx - $kodemkx - $statusy";
		echo "<br>";
		$sqlstr="update registrasi set status='$statusy' where nrp='$nrpx' and kodemk='$kodemkx'";
		$hasil=mysql_query($sqlstr);
	} while ($row=mysql_fetch_row($hasil1));
	echo "All done."
?>